package com.ruoyi.admin.service.impl;
import com.ruoyi.admin.service.ResourcesService;
import com.ruoyi.app.domain.PictureInfo;
import com.ruoyi.app.domain.VideoInfo;
import com.ruoyi.app.mapper.PictureInfoMapper;
import com.ruoyi.app.mapper.VideoInfoMapper;
import com.ruoyi.framework.web.domain.AjaxResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;

/*
@description:资源维护
@ClassName ResourcesServiceImpl
@author chen
@create 2025-03-13 23:11
@Version 1.0
*/
@Slf4j
@Service
@AllArgsConstructor
public class ResourcesServiceImpl implements ResourcesService
{
    final VideoInfoMapper videoInfoMapper;
    final PictureInfoMapper pictureInfoMapper;

    /*
     * @==============History===============<br/>
     * @Description //   视频上传
     * @Date 2025-3-13 23:32
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.domain.AjaxResult
     */
    @Override
    public AjaxResult insertVideoInfo(VideoInfo videoInfo)
    {
        videoInfo.setCreateTime(new Date());
        videoInfo.setUpdateTime(new Date());
        videoInfo.setDisable(false);
        return videoInfoMapper.insertSelective(videoInfo) > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    /*
     * @==============History===============<br/>
     * @Description //   视频资源更新
     * @Date 2025-3-13 23:34
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return com.ruoyi.framework.web.domain.AjaxResult
     */
    @Override
    public AjaxResult updateVideoInfo(VideoInfo videoInfo)
    {
        videoInfo.setUpdateTime(new Date());
        return videoInfoMapper.updateByPrimaryKeySelective(videoInfo) > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    /*
     * @==============History===============<br/>
     * @Description //   获取视频列表
     * @Date 2025-3-13 23:35
     * @Author < a href="15991488967@163.com">chen</ a>
     * @return java.util.List<com.ruoyi.app.domain.VideoInfo>
     */
    @Override
    public List<VideoInfo> getVideoList(Map<String, Object> params)
    {
        return videoInfoMapper.selectByExample(null);
    }


    /*
     * @==============History===============<br/>;
     * @Description //   新增首页图片资源信息
     * @Date 2025/3/14
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @Override
    public AjaxResult insertPictureInfo(PictureInfo pictureInfo)
    {
        pictureInfo.setCreateTime(new Date());
        pictureInfo.setUpdateTime(new Date());
        pictureInfo.setDisable(false);
        return pictureInfoMapper.insertSelective(pictureInfo) > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    /*
     * @==============History===============<br/>;
     * @Description //   更新首页图片资源信息
     * @Date 2025/3/14
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @Override
    public AjaxResult updatePictureInfo(PictureInfo pictureInfo)
    {
        pictureInfo.setUpdateTime(new Date());
        return pictureInfoMapper.updateByPrimaryKeySelective(pictureInfo) > 0 ? AjaxResult.success() : AjaxResult.error();
    }

    /*
     * @==============History===============<br/>;
     * @Description //   获取首页图片资源列表
     * @Date 2025/3/14
     * @Author < a href="chencheng@prmt.net">chen</ a>;
     */
    @Override
    public List<PictureInfo> getPictureInfoList(Map<String, Object> params)
    {
//        PictureInfoExample pictureInfoExample = new PictureInfoExample();
//        pictureInfoExample.createCriteria().andDisableEqualTo(false);
        return pictureInfoMapper.selectByExampleWithBLOBs(null);
    }
}
